﻿using Flurl;
using ZilLion.Core.Unities.UnitiesMethods;
using ZilLion.TaskManager.Entity.Config;
using ZilLion.TaskManager.Entity.Entity;
using ZilLion.TaskManager.Entity.Response;

namespace ZilLion.TaskManager.Repository
{
    public class TaskNodeInfoRespository : ITaskNodeInfoRespository
    {
        public NodeServerResponse NodeHeartbeat(string nodeid)
        {
            var nodeInfoEntity = new NodeInfoEntity
            {
                Nodeid = nodeid,
                Nodename = string.Empty,
                Nodepcname = SysHelper.ComputerName,
                Nodeip = Computer.IpAddress,
                Nodemac = Computer.MacAddress,
                Noderemark = string.Empty
            };

            var url = Url.Combine(TaskManagerGlobalSetting.GetInstance().ManagerServiceHost, "Api",
                "TaskPlatform",
                "Node", "NodeHeartbeat"
            );

            var response = HttpHelper.HttpRequestPost<NodeInfoEntity, NodeServerResponse>($"{url} ", nodeInfoEntity);
            return response;
        }
    }
}